﻿using Caliburn.Micro;
using Ninject;
using Spotted.Core;
using Spotted.Data.Repositories;

namespace Spotted.ViewModels
{
    public class RegisterPageViewModel : ViewModelBase
    {
        [Inject]
        public IUserRepository UserRepository { get; set; }

        [Inject]
        public IAppService ApplicationService { get; set; }

        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string EmailAddress { get; set; }
        public string Password { get; set; }
        public string ConfirmPassword { get; set; }

        public RegisterPageViewModel(INavigationService navigationService) : base(navigationService)
        {
        }

        // behaviors
        public void AddUser()
        {
            UserRepository.CreateUserCompleted += UserRepository_CreateUserCompleted;
            ApplicationService.ShowProgressIndicator("registering...");

            // TODO: Hash the password
            UserRepository.CreateUser(EmailAddress, Password, FirstName, LastName);
        }

        void UserRepository_CreateUserCompleted(object sender, Data.Args.UserActionCompleteValidEventArgs e)
        {
            
        }
    }
}
